package com.titaniume.activitiweb;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 *@program: activiti7_workflow
 *@description: 流程定义
 *@author: renfei.huang
 *@create: 2021-11-09 13:59
 */
@SpringBootTest
public class Part2_ProcessDefinition {

    @Autowired
    private RepositoryService repositoryService;

    //查询流程定义 act_re_procdef
    @Test
    public void  getDefinitions(){
        List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list();
        for (ProcessDefinition processDefinition : list) {
            System.out.println("Name:" + processDefinition.getName());
            System.out.println("Key:" + processDefinition.getKey());
            System.out.println("ResourceName:" + processDefinition.getResourceName());
            System.out.println("DeploymentId:" + processDefinition.getDeploymentId());
            System.out.println("Version :" + processDefinition.getVersion());
        }

    }

    @Test
    public  void delDefinition(){
        //PdId 不存在就会报错
        String PdId = "6d751520-410e-11ec-881d-8cec4b5c0c44";
        repositoryService.deleteDeployment(PdId,true);
        System.out.println("删除流程定义成功");
    }
}
